* Setup for restricted ANES occupation codes.
*
* The excel files including respondent occupations are stored in a password 
* protected folder. The folder must be mounted before running the code.


set more off


* Import excel files, save for merging with public ANES data.

foreach yr of numlist 1986(2)2000 2004 {
import excel /Volumes/ANES_OccupationCodes/ANES_Restricted_`yr'TS_CensusOccPres.xls, firstrow clear
drop if caseid == .
* Change name of variable occupation code to match census crosswalks.
if Census1[_n] == 1980 {
	rename R_occ1 occ1980
	}
else if Census1[_n] == 1990 {
	rename R_occ1 occ1990
	}
else if Census1[_n] == 2000 {
	rename R_occ1 occ2000
	}
*

rename tsyear year
keep year caseid R_status occ*

#delimit ;
label define lab_status 
	10 "Working now only"
	15 "Retired and working 20 or more hours per week"
	16 "Permanently disabled and working 20 or more hours per week"
	17 "Homemaker and working 20 or more hours per week"
	18 "Student and working 20 or more hours per week"
	20 "Temporarily laid off"
	40 "Unemployed"
	50 "Retired only"
	51 "Retired and working less than 20 hours per week"
	60 "Permanently disabled only"
	61 "Permanently disabled and working less than 20 hours per week"
	70 "Homemaker only"
	71 "Homemaker and working less than 20 hours per week"
	75 "Homemaker and student"
	80 "Student only"
	81 "Student and working less than 20 hours per week" ;
#delimit cr
label values R_status lab_status 


save /Volumes/ANES_OccupationCodes/ANES_Restricted_Occ_`yr'.dta, replace
}
*

clear

